home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / paircont.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  2KB  |  62 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef pair_content
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_paircont = "$Header: C:\CURSES\portable\RCS\paircont.c 2.1 1993/06/18 20:20:42 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   pair_content()    - Obtain color-pair information.
  15.  
  16.   PDCurses Description:
  17.  
  18.      This routine is used to determine what the colors of a given color-pair
  19.      consist of.
  20.  
  21.      The routine uses three arguments: the colorpair number which
  22.      must be a value between 1 and COLOR_PAIRS-1 and the adresses of
  23.      two shorts for storing the obtained color components of foreground
  24.      and background. The function will store the current values at these
  25.      addresses passed. The values will be between 0 and COLORS-1.
  26.  
  27.   PDCurses Return Value:
  28.      This function returns OK on success and ERR on error.
  29.  
  30.   PDCurses Errors:
  31.      It is an error to call this function with a colorpair outside of the
  32.      range specified above.
  33.  
  34.   Portability:
  35.      PDCurses    int pair_content( int colorpair, short *foreground, short *background);
  36.      SYS V Curses    int pair_content( int colorpair, short *foreground, short *background);
  37.  
  38. **man-end**********************************************************************/
  39.  
  40.  
  41. int pair_content(int colorpair,short *foreground,short *background)
  42. {
  43.  extern int COLOR_PAIRS;
  44.  extern unsigned char atrtab[MAX_ATRTAB];
  45.  
  46. #ifdef PDCDEBUG
  47.     if (trace_on) PDC_debug("pair_content() - called: colorpair %d fore %d back %d\n",colorpair,foreground,background);
  48. #endif
  49.  
  50.  if (colorpair >= COLOR_PAIRS || colorpair < 1)
  51.     return(ERR);
  52.  
  53. #ifdef CHTYPE_LONG
  54.  *foreground = (short)(atrtab[colorpair] & 0x0F);
  55.  *background = (short)((atrtab[colorpair] & 0xF0)>>4);
  56. #else
  57.  *foreground = (short)(atrtab[colorpair*8] & 0x0F);
  58.  *background = (short)((atrtab[colorpair*8] & 0xF0)>>4);
  59. #endif
  60.  return(OK);
  61. }
  62.